package cz.fit.dpo.task1;

/**
 * class for representing items in this game
 */
public class Item {
	
	/**
	 * name of this item
	 */
	private String name;
	
	/**
	 * owner of this item
	 */
	private IHaveItem owner;

	/**
	 * is this item movable?
	 */
	private boolean movable;
	
	/**
	 * constructs this item with given name and sets that this item is movable
	 */
	public Item (String name) {
		setName (name);
		setMovable(true);
	}
	
	/**
	 * constructs this item with given name and defines whether this item is movable
	 */
	public Item (String name, boolean movable) {
		setName (name);
		setMovable(movable);
	}
	
	/**
	 * gets the name of this item
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * sets the name of this item
	 */
	private void setName(String name) {
		this.name = name.replace(World.UNMOVABLE, "");
	}
	
	/**
	 * gets who's owner of this item
	 */
	public IHaveItem getOwner() {
		return owner;
	}
	
	/**
	 * sets who's owner of this item
	 */
	public void setOwner(IHaveItem owner) {
		this.owner = owner;
	}
	
	/**
	 * gets whether this item is movable
	 */
	public boolean isMovable() {
		return movable;
	}
	
	/**
	 * sets whether this item is movable
	 */
	private void setMovable(boolean movable) {
		this.movable = movable;
	}
	
	@Override
	public String toString() {
		return name;
	}

}
